#include <iostream>

using namespace std;

const int maxn = 1e5 + 1000;
int a[maxn];

int main()
{
    string s1;
    int n, i, m, j, t;
    cin >> m;
    int head = 0, tail = 0;
    for (i = 0; i < m; i++) 
    {
        cin >> s1;
        if (s1 == "push") 
        {
            cin >> n;
            a[head++] = n;
        }
        else if (s1 == "pop") 
        {
            if (tail == head) 
            {
                cout << "error" << endl;
                continue;
            }
            cout << a[tail] << endl;
            tail++;
        }
        else if (s1 == "front") 
        {
            if (tail == head) 
            {
                cout << "error" << endl;
                continue;
            }
            cout << a[tail] << endl;
        }
    }

    return 0;
}

